package com.panku.core.entity;

import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import java.lang.reflect.Parameter;

import com.panku.MyRequestMethod;
import com.panku.annocation.myRequestParam;

public class ClassBean {

	/**
	 * 类的类对象
	 */
	private Class<?> clazz;
	/**
	 * 对应的方法
	 */
	private Method method;
	/**
	 * 请求的类型:get/post
	 */
	private MyRequestMethod resMethod;
	
	public ClassBean(){}
	
	public ClassBean(Class<?> clazz,Method method,MyRequestMethod resMethod){
		this.clazz=clazz;
		this.method=method;
		this.resMethod=resMethod;
	}
	
	
	public Class<?> getClazz() {
		return clazz;
	}


	public void setClazz(Class<?> clazz) {
		this.clazz = clazz;
	}


	public Method getMethod() {
		return method;
	}


	public void setMethod(Method method) {
		this.method = method;
	}


	public MyRequestMethod getResMethod() {
		return resMethod;
	}


	public void setResMethod(MyRequestMethod resMethod) {
		this.resMethod = resMethod;
	}


	public void test(@myRequestParam("name")String name,@myRequestParam("age")Integer age){
		System.out.println("进入~!");
	}
	
	
	public static void main(String[] args) {
		ClassBean cb=new ClassBean();
		Class<?> cbClazz=cb.getClass();
		try {
			Method cbMethod = cbClazz.getMethod("test",new Class<?>[]{String.class,Integer.class});
			if (cbMethod.getParameterCount()>0) {
				Parameter[] params = cbMethod.getParameters();
				Object[] paramArr=new Object[params.length];
				for (Parameter parameter : params) {
					myRequestParam[] annotations= parameter.getAnnotationsByType(myRequestParam.class);
					for (myRequestParam annotation : annotations) {
						System.out.println(annotation.value());
					}
				}
			}
		} catch (NoSuchMethodException | SecurityException e) {
			e.printStackTrace();
		}
		
	}
	
}
